﻿<Window x:Class="ICSharpCode.SharpDevelop.Project.PortableLibrary.SelectProfileDialog" x:ClassModifier="internal"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Project.PortableLibrary"
        xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
        Title="{core:Localize PortableLibrary.SelectProfileDialog.Title}" 
        MinWidth="300" MinHeight="200" Height="350" Width="400" WindowStartupLocation="CenterOwner"
        Style="{x:Static core:GlobalStyles.DialogWindowStyle}">
	<Grid>
		<Grid.Resources>
			<widgets:BoolToVisibilityConverter x:Key="showWhenTrue" TrueValue="Visible" FalseValue="Collapsed" />
			<widgets:BoolToVisibilityConverter x:Key="showWhenFalse" TrueValue="Collapsed" FalseValue="Visible" />
		</Grid.Resources>
		<Grid.RowDefinitions>
			<RowDefinition
				Height="1*" />
			<RowDefinition
				Height="Auto" MinHeight="50" />
			<RowDefinition
				Height="Auto" />
		</Grid.RowDefinitions>
		<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
			<ItemsControl ItemsSource="{Binding SupportedFrameworkGroups}" Margin="8">
				<ItemsControl.ItemsPanel>
					<ItemsPanelTemplate>
						<widgets:StackPanelWithSpacing Orientation="Vertical" SpaceBetweenItems="10"/>
					</ItemsPanelTemplate>
				</ItemsControl.ItemsPanel>
				<ItemsControl.ItemTemplate>
					<DataTemplate DataType="{x:Type local:SupportedFrameworkGroup}">
						<StackPanel Orientation="Vertical">
							<CheckBox IsChecked="{Binding IsChecked}" Content="{Binding DisplayName}" FontWeight="Bold" />
							<ComboBox Name="comboBox" ItemsSource="{Binding AvailableVersions}" SelectedItem="{Binding SelectedVersion}"
							          Margin="20,0,0,0" IsEnabled="{Binding IsChecked}" />
						</StackPanel>
						<DataTemplate.Triggers>
							<DataTrigger Binding="{Binding AvailableVersions.Count}" Value="1">
								<DataTrigger.Setters>
									<Setter TargetName="comboBox" Property="Visibility" Value="Collapsed" />
								</DataTrigger.Setters>
							</DataTrigger>
						</DataTemplate.Triggers>
					</DataTemplate>
				</ItemsControl.ItemTemplate>
			</ItemsControl>
		</ScrollViewer>
		<TextBlock Grid.Row="1" TextWrapping="WrapWithOverflow" Visibility="{Binding HasTwoOrMoreFrameworksSelected, Converter={StaticResource showWhenTrue}}">
			<Bold><Run Text="{core:Localize PortableLibrary.SelectedProfile}"/></Bold> <Run Text="{Binding SelectedProfile.DisplayName, Mode=OneWay}"/>
		</TextBlock>
		<TextBlock Grid.Row="1" TextWrapping="WrapWithOverflow" Visibility="{Binding HasTwoOrMoreFrameworksSelected, Converter={StaticResource showWhenFalse}}">
			<Bold><Run Text="{core:Localize PortableLibrary.SelectAtLeastTwoFrameworks}"/></Bold>
		</TextBlock>
		<widgets:UniformGridWithSpacing Columns="2" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" Margin="0,4,12,12">
			<Button
				Content="{core:Localize Global.OKButtonText}"
				IsDefault="True"
				Click="okButton_Click"
				IsEnabled="{Binding HasTwoOrMoreFrameworksSelected}"
				Style="{x:Static core:GlobalStyles.ButtonStyle}" />
			<Button
				Content="{core:Localize Global.CancelButtonText}"
				IsCancel="True"
				Style="{x:Static core:GlobalStyles.ButtonStyle}" />
		</widgets:UniformGridWithSpacing>
	</Grid>
</Window>